<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html>
<html>
<head>
<title>辽地集团网络集中采购平台</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="${pageContext.request.contextPath}/jquery-ui/jquery-ui.min.css">
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/main.css" />
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/jquery-ui/jquery-ui.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/api.js"></script>
<script type="text/javascript">
$(function() {
    
    var urlPrefix = "${pageContext.request.contextPath}/api/";

	var tenderAPI = new TenderAPI({
		urlPrefix : urlPrefix
	});
	
	var newsNoticeAPI = new NewsNoticeAPI({
		urlPrefix : urlPrefix
	});
	
	getTenderInformation({
	    onSuccess: function(tenders) {
	        $('#tender_list').children('li').remove();
	        $.each(tenders, function(index, row) {
	            var title = '';
	            if (row.status == 1) {
	                title = '招标预告';
	            } else {
	                title = '招标公告';
	            }
	            $('#tender_list').append('<li><a href="#" style="color: red;">[' + title + ']</a>&nbsp;<a href="${pageContext.request.contextPath}/forward/tender_detail?tenderId=' + row.tender_id + '" title="' + row.tender_title + '" target="_blank">' + row.tender_title + '</a></li>');
	        });
	    }
	});
	
	getNewsNotice(3, {
	    onSuccess: function(tenders) {
	        $('#bid_notice_list').children('li').remove();
	        $.each(tenders, function(index, row) {
	            $('#bid_notice_list').append('<li><a href="#" style="color: red;">[中标公告]</a>&nbsp;<a href="${pageContext.request.contextPath}/forward/news_notice_detail?newsNoticeId=' + row.news_notice_id + '" title="' + row.title + '" target="_blank">' + row.title + '</a></li>');
	        });
	    }
	});
	
	getNewsNotice(2, {
	    onSuccess: function(tenders) {
	        $('#finalist_notice_list').children('li').remove();
	        $.each(tenders, function(index, row) {
	            $('#finalist_notice_list').append('<li><a href="#" style="color: red;">[入围公告]</a>&nbsp;<a href="${pageContext.request.contextPath}/forward/news_notice_detail?newsNoticeId=' + row.news_notice_id + '" title="' + row.title + '" target="_blank">' + row.title + '</a></li>');
	        });
	    }
	});
	
	getNewsNotice(1, {
	    onSuccess: function(tenders) {
	        $('#news_notice_list').children('li').remove();
	        $.each(tenders, function(index, row) {
	            $('#news_notice_list').append('<li><a href="${pageContext.request.contextPath}/forward/news_notice_detail?newsNoticeId=' + row.news_notice_id + '" title="' + row.title + '" target="_blank">' + row.title + '</a></li>');
	        });
	    }
	});
	
	function getTenderInformation(callback) {
		var paramData = {};
		paramData.status = new Array(1, 2, 3, 4);
		tenderAPI.search({
			onSuccess : function(data) {
			    if (callback) {
			        if (data.total > 0) {
			            if (callback.onSuccess && typeof(callback.onSuccess) == "function") {
			                callback.onSuccess(data.tenders);
			            }
					} else {
					    if (callback.onError && typeof(callback.onError) == "function") {
			                callback.onError();
			            }
					}
			    }
			},
			onAPIError : function(status, errors) {
			},
			onServerError : function(jqXHR, textStatus, errorThrown) {
			}
		}, {
			param : JSON.stringify(paramData),
			page : 1,
			rows : 25
		});
	}
	
	function getNewsNotice(category, callback) {
		var paramData = {};
		paramData.category = category;
		newsNoticeAPI.search({
			onSuccess : function(data) {
			    if (callback) {
			        if (data.recordsTotal > 0) {
			            if (callback.onSuccess && typeof(callback.onSuccess) == "function") {
			                callback.onSuccess(data.news_notice);
			            }
					} else {
					    if (callback.onError && typeof(callback.onError) == "function") {
			                callback.onError();
			            }
					}
			    }
			},
			onAPIError : function(status, errors) {
			},
			onServerError : function(jqXHR, textStatus, errorThrown) {
			}
		}, {
			param : JSON.stringify(paramData),
			start : 0,
			length :12
		});
	}
});
</script>
</head>
<body>
  <div style="text-align: center;" align="center">
    <jsp:include page="top.jsp" />
    <div id="content" style="width: 1000px; height: 600px; margin: 0 auto; margin-top: 10px;">
      <div id="left" style="border: 1px solid #eee; float: left; height: 590px; width: 358px; text-align: left; padding: 5px;">
        <label style="font-size: 15px; font-weight: bold; width: 358px; height:35px; border-bottom: 1px double #ccc; text-shadow: 2px 2px 1px #ccc;">最新招标信息</label>
        <a href="tender_search" style="float: right;">更多&gt;&gt;</a>
        <ul id="tender_list" style="list-style: none; width: 358px; margin-top: 5px; font-size: 13px;"></ul>
      </div>
      <div id="center-top" style="border: 1px solid #eee; float: left; height: 285px; width: 358px; text-align: left; margin-left: 4px; padding: 5px;">
        <label style="font-size: 15px; font-weight: bold; width: 358px; height:35px; border-bottom: 1px double #ccc; text-shadow: 2px 2px 1px #ccc;">中标公告</label>
        <a href="news_notice?category=3" style="float: right;">更多&gt;&gt;</a>
        <ul id="bid_notice_list" style="list-style: none; width: 358px; margin-top: 5px; font-size: 13px;"></ul>
      </div>
      <div id="right-top" style="border: 1px solid #eee; float: right; height: 285px; width: 240px; text-align: left; padding: 5px;">
        <label style="font-size: 15px; font-weight: bold; width: 240px; height:35px; border-bottom: 1px double #ccc; text-shadow: 2px 2px 1px #ccc;">新闻通告</label>
        <a href="news_notice?category=1" style="float: right;">更多&gt;&gt;</a>
        <ul id="news_notice_list" style="list-style: none; width: 358px; margin-top: 5px; font-size: 13px;"></ul>
      </div>
      <div id="center-bottom" style="border: 1px solid #eee; float: left; height: 285px; width: 358px; text-align: left; margin-left: 4px; margin-top: 8px; padding: 5px;">
        <label style="font-size: 15px; font-weight: bold; width: 358px; height:35px; border-bottom: 1px double #ccc; text-shadow: 2px 2px 1px #ccc;">入围公告</label>
        <a href="news_notice?category=2" style="float: right;">更多&gt;&gt;</a>
        <ul id="finalist_notice_list" style="list-style: none; width: 358px; margin-top: 5px; font-size: 13px;"></ul>
      </div>
      <div id="right-bottom" style="border: 1px solid #eee; float: right; height: 285px; width: 240px; text-align: left; margin-top: 8px; padding: 5px;">
        <label style="font-size: 15px; font-weight: bold; width: 240px; height:35px; border-bottom: 1px double #ccc; text-shadow: 2px 2px 1px #ccc;">会员展示</label>
      </div>
    </div>
    <div id="footer"><s:text name="copyright" /></div>
  </div>
</body>
</html>
